import json
import os


def handle_string_list():
    # class OperaPlot(db.Model):
    #     opr_name = db.Column(db.String(50), db.ForeignKey('opera.opr_name'), primary_key=True)
    #     name = db.Column(db.String(50), primary_key=True)
    #     plot = db.Column(db.Text)
    # 扫描目录
    p = 'intro'
    my_dir = './' + p + '/'
    file_list = os.listdir(my_dir)
    out = open('./string-list-script.txt', mode='w', encoding='utf-8')
    for f in file_list:
        fin = open(my_dir + f, mode='r', encoding='utf-8')
        string_list = []
        while True:
            fread = fin.readline()
            if not fread:
                break
            string_list.append(fread.strip('\n'))
        str_res = json.dumps(string_list)
        print(str_res)
        out.write(str_res)
        out.write('\n')
    out.close()


if __name__ == "__main__":
    handle_string_list()
    pass
